$(function () {
    obj.init();
});

var obj = new function () {
    return {
        dataGrid: null,
        params: {
        },
        init: function () {
            this.dataGrid = new xhDataGrid($('#list'), 'class/getAutoClassError');
            this.dataGrid.parseToolbar().init().activeBtn(null, $('#bt_list_redo'));

            this.listener();
        },
        listener: function () {
            var $this = this;
            //绑定搜索事件
            xhTool.bindDocKeyDown(
                $('#bt_list_search').click(function(){
                    $this.funObj().search();
                })
            );
            //一键重试
            $('#bt_list_redo').click(function(){
                if(xhExtra.buttonDisabled($(this))) return false;
                $this.funObj().redo();
            });
        },
        funObj: function () {
            var $this = this;
            return {
                search: function (_return) {
                    $this.dataGrid.reload({
                        'status': xhExtra.getValue($('#list_status'))
                    });
                },
                redo: function () {
                    var id = $this.dataGrid.getSelectValue('id');
                    xhExtra.askChangeStatus('class/redoAutoClass', {id: id}, $this.dataGrid, '确认重试？');
                    // xhExtra.ajaxRequest('class/redoAutoClass', {id: id}, {check: true, success: true, table: $this.dataGrid});
                }
            }
        }
    }
}